package org.offsync.rich

import scala.collection.mutable.PriorityQueue

class RichPriorityQueue[T](priorityQueue: PriorityQueue[T]) {
  def dequeueWhile(f: T => Boolean): List[T] = {
    if (!priorityQueue.isEmpty) {
      if (f(priorityQueue.max)) {
        val value = priorityQueue.dequeue()
        return value :: dequeueWhile(f)
      }
    }

    return Nil
  }
}
